import requests
import time
import detect
import search
import compare
import analyze

def system(image_path,outer_id):
    """该函数为宿舍人脸识别系统的封装算法，设计者：蔡洪嘉；说明：按照说明输入相关资料，系统通过运算后得出是否为宿舍成员。【图片相对地址/绝对地址,宿舍楼栋指定编号】"""
    time_format = '%Y-%m-%d %X'
    time.strftime(time_format, time.localtime())
    search_result=search.face_search(image_path,outer_id)
#     if 'results' in search_result:
#         if search_result['results'][0]['confidence']< search_result['thresholds']['1e-3']:
#             print('十分抱歉！您不是该宿舍成员，请联系宿舍管理员。当前时间：',time.strftime(time_format, time.localtime()) )
#         else:
#             print('欢迎您回来宿舍！当前时间：',time.strftime(time_format, time.localtime()) )
#     else:
#         print('未识别到人脸，请重新识别！')
    if 'results' in search_result:
        if search_result['results'][0]['confidence']< search_result['thresholds']['1e-3']:
            result='十分抱歉！您不是该宿舍成员，请联系宿舍管理员。当前时间：'+time.strftime(time_format, time.localtime()) 
        else:
            result='欢迎您回来宿舍！当前时间：'+time.strftime(time_format, time.localtime())
    else:
        result ='未识别到人脸，请重新识别！'
    return print(result)
